/*
 Copyright (C) 2009 QDSS.org
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.qdss.topisv.api.response;

import org.qdss.topisv.api.ApiInvokeFailureException;


/**
 * Api调用出现错误结果
 * 
 * @author <a href="mailto:zhaofang123@gmail.com">FANGFANG ZHAO</a>
 * @since 0.1.0, Feb 6, 2010
 * @version $Id: ErrorRspException.java 70 2012-09-08 16:29:34Z zhaofang123 $
 */
public class ErrorRspException extends ApiInvokeFailureException {
	private static final long serialVersionUID = 6759002248031728346L;

	private ErrorRsp errorRsp;
	
	/**
	 * @param message
	 */
	protected ErrorRspException(String message) {
		super(message);
	}
	
	/**
	 * @param errorRsp
	 */
	public ErrorRspException(ErrorRsp errorRsp) {
		super(errorRsp.toString());
		this.errorRsp = errorRsp;
	}
	
	/**
	 * @param message
	 * @param errorRsp
	 */
	public ErrorRspException(String message, ErrorRsp errorRsp) {
		super(message);
		this.errorRsp = errorRsp;
	}
	
	static final ErrorRsp UNKNOW_ERROR = new ErrorRsp("unknow.error", "-9999", "未知错误");
	/**
	 * @return
	 */
	public ErrorRsp getErrorRsp() {
		return errorRsp == null ? UNKNOW_ERROR : errorRsp;
	}
}
